package org.zhongyin.internal.core;


import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import jxl.read.biff.BiffException;

import org.zhongyin.Dao.ARCIVE_DBDaoImpl;
import org.zhongyin.JPA.Entity.PermanentHistoryData;
import org.zhongyin.core.IData;
import org.zhongyin.core.INoaaDataWeek;


public class NoaaDataWeekend implements INoaaDataWeek{
	private IData histNoaaData;
	private IData forcastNoaaData;
	
	
	public NoaaDataWeekend() throws BiffException, IOException {
		this.histNoaaData = new NoaaData();
		this.forcastNoaaData = new NoaaData();
	}
	
	
	/**
	 * @param histNoaaData the histNoaaData to set
	 * @throws ParseException 
	 */
	protected void setHistNoaaData() throws ParseException {
		ARCIVE_DBDaoImpl dao = new ARCIVE_DBDaoImpl();
		
		List<Object[]> rData =dao.getRecentData();
		List<Object[]> today =dao.getTodayData();
		List<PermanentHistoryData> clData = dao.getHistCLData();
		histNoaaData.read(dao.combineHistData(today, rData, clData));
	}
	/**
	 * 
	 * @return return the HistnooaData from Database 
	 * @throws ParseException 
	 */
	protected IData getHistNoaaData(){
		return this.histNoaaData;
		
	}
	
	protected void setForcastNoaaData() throws ParseException {
		ARCIVE_DBDaoImpl dao = new ARCIVE_DBDaoImpl();

		 List<Object[]> rData =dao.getRecentData();
		 List<Object[]> today =dao.getTodayData();
		 List<PermanentHistoryData> clData = dao.getHistCLData();
		 List<Object[]> combine = dao.combineHistData(today, rData, clData);
		 
//		 Utility.printArrayList(combine);

//		 System.out.println("-------------------------------------------");

		
		 List<Object[]> next24hours = dao.getForcastNext24Hours();
		 
//		 Utility.printArrayList(next24hours);
		 
//		 System.out.println("-------------------------------------------");
		 List<Object[]> combine24 = dao.combineNext24HoursData(next24hours, combine);
		 forcastNoaaData.read(combine24);
	}
	
	protected IData getForcastNoaaData(){
		return this.forcastNoaaData;
		
	}
	
	
}
